# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=sexpect
pkgver=2.3.8
pkgrel=0
pkgdesc="expect designed for shell scripts"
url="https://github.com/clarkwang/sexpect"
arch="all"
license="GPL-3.0-only"
makedepends="
	cmake
	samurai
	"
checkdepends="
	bash
	procps
	"
subpackages="$pkgname-doc"
source="https://github.com/clarkwang/sexpect/archive/v$pkgver/sexpect-$pkgver.tar.gz"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		local crossopts="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_VERBOSE_MAKEFILE=ON \
		-DCMAKE_C_FLAGS="$CFLAGS -D_GNU_SOURCE" \
		$crossopts
	cmake --build build
}

check() {
	local skip='interact-re-helper'
	case "$CARCH" in
		s390x) skip="$skip|spawn-discard"  # FIXME
	esac

	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest --exclude-regex "$skip"
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
11a473cb733f93f06fe4c29f9d03ba195481809b325f4bf9649415c2e2eca5f5afa9ec80fd56ac77afd03bdfe90984200a7a1317298369f85b2bb02c25978cec  sexpect-2.3.8.tar.gz
"
